import java.awt.Graphics;
import java.awt.Color;
import java.util.Random;
import java.lang.Math;

public class Star {
	private int num = 400;

	private int[] x = new int[num];
	private int[] y = new int[num];
	private int speed;
	private int step = 100;

	private double[] offset = new double[num];

	private Color starColor = new Color(5, 48, 80);
	
	public Star() {
		Random gen = new Random();
		speed = step;
		
		for (int i = 0; i < num; ++i) {
			x[i] = gen.nextInt(800);
			y[i] = gen.nextInt(500) - 80;
		}
	}
	
	public void paintStars(Graphics g) {
	
		updatePosition();
				
		g.setColor(Color.white);
		for (int i = 0; i < num; ++i) {
			int size = i % 3 + 1;
			g.fillOval(x[i], y[i] + (int)offset[i], size, size);
		}
	}
	
	private void updatePosition() {
	
	    if (speed == 0) {
		
		    for (int i = 0; i < num; ++i) {
			    x[i] = x[i] + 1;
			    if (x[i] > 800)
			    	x[i] = 0;
			    offset[i] = - 125 * Math.sin(x[i] * Math.PI / 800) + 80;
		    }
		    speed = step;
		}
		else
		    --speed;
		}
}
